LIBSUFFIX = .cma
LIBNAMES = bigarray sdl gl unix
LIBPATHS = -I /usr/lib/ocaml/3.09.1/sdl -I /usr/lib/ocaml/3.09.1/camlgl 

MODS = vec matrix syst ogl scene glu camera roam 3d

SUFFIX = .cmo
OC = ocamlc

SOURCES = $(addsuffix .ml, $(MODS))
OBJS = $(addsuffix $(SUFFIX), $(MODS))
LIBS = $(addsuffix $(LIBSUFFIX), $(LIBNAMES))

%$(SUFFIX) : %.ml
	$(OC) $(LIBPATHS) -c $^

3d : $(OBJS) glum.o
	$(OC) $(LIBPATHS) $(LIBS) -cclib /usr/lib/libGLU.so.1 $(OBJS) -custom glum.o -o 3d

glum.o : glum.c
	gcc -c glum.c

doc : $(SOURCES)
	ocamldoc $(LIBPATHS) -html $^ -d doc
	ocamldoc $(LIBPATHS) -dot $^ -o doc/dep.dot

mktop :
	ocamlmktop bigarray.cmx $(LIBPATHS) $(LIBS)

clean :
	rm -f *.cmo
	rm -f *.cmi
	rm -f *.cmx
	rm -f 3d
	rm -f *.o